<template>
  <div style="height: 100%; width: 100%; position: relative">
      <div class="pagetop" ref="buttondiv">
          <div style="width: 100%">
              <table style="width: 100%; font-size: 12px; white-space: nowrap; max-width: 1350px">
                  <tr>
                      <td width="60">快速查找</td>
                      <td width="150">
                          <el-input style="width: 150px" v-model="searchtext" placeholder="代码、名称、简称、输入码、his代码"></el-input>
                      </td>
                      <td width="60">分单类别</td>
                      <td width="150">
                          <rm-ddl-common datatype="reqgroup" dataname="分单类别" v-model="reqgroupval" :appendtobody="true" @change="reqgroupchange" width="150px" key="14"></rm-ddl-common>
                      </td>
                      <!-- <td width="80" style="text-align:left">
                          <el-checkbox label="仅显示开单画面项目" v-model="onlyshow" @change="ShowMain"></el-checkbox>
                      </td> -->
                      <td width="60">项目归类</td>
                      <td width="120">
                          <!-- <el-input style="width: 120px" v-model="searchitemclasscode"  clearable></el-input> -->
                          <rm-ddl-reqitemclass v-model="searchitemclasscode" width="150px"></rm-ddl-reqitemclass>
                      </td>
                      <td width="60">采样时间字典</td>
                      <td style="width:120px">
                          <rm-ddl-common width="100%" datatype="collectdict" dataname="采样时间" v-model="searchcollectdictid" :appendtobody="true" ref="autofocus34" key="15"></rm-ddl-common>
                      </td>

                      <td width="60px">单价区间</td>
                      <td width="50px">
                          <el-input style="width:50px" v-model="searchitem_price1" oninput="value=value.replace(/[^0-9.]/g,'')" clearable></el-input>-
                      </td>
                      <td width="50px">
                          <el-input v-model="searchitem_price2" style="width:50px" oninput="value=value.replace(/[^0-9.]/g,'')" clearable></el-input>
                      </td>

                      <td width="100" style="text-align: center ;">
                          <el-checkbox true-label="1" false-label="0" v-model="searchoutflag">外送项目</el-checkbox>
                      </td>

                      <td width="180" style="text-align: right ;">
                          <!-- <el-checkbox label="禁用" v-model="disabledflag" @change="ShowMain"></el-checkbox> -->
                          <el-radio-group v-model="disabledflag" @change="ShowMain">
                              <el-radio :label="0">全部</el-radio>
                              <el-radio :label="1">禁用项目</el-radio>
                              <el-radio :label="2">在用项目</el-radio>
                          </el-radio-group>
                      </td>

                  </tr>
              </table>
              <div class="operation-list">
                  <el-button @click="ShowMain()" icon="el-icon-search" v-has="'PINQUERY'" v-show="editvisible">查询</el-button>
                  <el-button @click="OpenDialog(1)" icon="el-icon-plus" v-has="'PADD'" v-show="editvisible">新增</el-button>
                  <el-button @click="OpenDialog(2)" icon="el-icon-edit" v-has="'PMODIFY'" v-show="editvisible" :disabled="isused">修改</el-button>
                  <el-button @click="OpenDialog(3)" icon="el-icon-delete" v-has="'PDELETE'" v-show="editvisible" :disabled="isused">删除</el-button>
                  <el-button @click="Copy()" icon="el-icon-news" v-show="copyvisible">复制</el-button>
                  <el-button @click="syncdata" icon="el-icon-position" v-has="'PSYNC'" v-show="editvisible">同步</el-button>
                  <el-button @click="clearcache" v-show="editvisible">清理缓存</el-button>
                  <!-- <el-button @click="syncdata" icon="el-icon-position" v-has="'PSYNC'" v-if="isshow" v-show="syncvisible">同步</el-button> -->
                  <!-- <el-button @click="savesyncdata" icon="el-icon-files" v-has="'PSYNC'" v-else v-show="syncvisible">保存同步</el-button> -->
                  <el-button @click="Paste()" icon="el-icon-news" v-show="copyvisible">粘贴</el-button>
                  <el-button @click="AddRecord()" icon="el-icon-plus" v-show="recordvisible" :disabled="curtabindex=='4'&&!LIS113addauth">新增明细</el-button>
                  <el-button @click="DelRecord()" icon="el-icon-delete" v-show="recordvisible" :disabled="curtabindex=='4'&&!LIS113delauth">删除明细</el-button>
                  <el-button @click="SaveRecord()" icon="el-icon-files" v-show="savevisible" :disabled="curtabindex=='4'&&!LIS113modauth">保存</el-button>
                  <el-button @click="setExportColumn">导出列设置</el-button>
                  <el-button @click="BtnExport" icon="el-icon-download">导出</el-button>
              </div>
          </div>
      </div>
      <div class="pagecenter">
          <rm-layout-right splitcolor="#ffffff" :splitwidth="3" :fixsize="800" :minfixsize="200" ref="layoutright">
              <div ref="xTableDiv" style="height: 100%">
                  <vxe-table ref="xTable" :data="list" :loading="loading" :keyboard-config="keyConfig" :keyboard-local-config="keyLocalConfig" :select-config="{ trigger: 'row' }" :sort-config="{ trigger: 'cell' }" @current-change="currentChangeEvent" border fit height="auto" header-align="center" highlight-current-row highlight-hover-row highlight-hover-column resizable show-header-overflow="tooltip" show-overflow="tooltip" size="mini" stripe :row-class-name="rowClassName">
                      <vxe-table-column field="req_groupname" title="分单类别" width="80"></vxe-table-column>
                      <vxe-table-column field="req_itemcode" title="申请项目代码" width="120"></vxe-table-column>
                      <vxe-table-column field="req_itemname" title="申请项目名称" width="150"></vxe-table-column>
                      <vxe-table-column field="hospcode" title="医院代码" width="80"></vxe-table-column>
                      <vxe-table-column field="his_itemcode" title="HIS对应项目代码" width="80"></vxe-table-column>
                      <vxe-table-column field="req_itemna" title="项目简称" width="120"></vxe-table-column>
                      <vxe-table-column field="req_itemname_en" title="项目英文名称" width="120"></vxe-table-column>
                      <vxe-table-column field="create_bylis" title="自建" width="50" align="center"></vxe-table-column>
                      <vxe-table-column field="his_class" title="HIS项目类别" width="80"></vxe-table-column>
                      <vxe-table-column field="his_itemname" title="HIS项目名称" width="120"></vxe-table-column>
                      <vxe-table-column field="perform_deptname" title="执行科室" width="120"></vxe-table-column>
                      <vxe-table-column field="inputcode" title="助记符" width="80"></vxe-table-column>
                      <vxe-table-column field="item_price" title="价格" width="60" align="right" header-align="center"></vxe-table-column>
                      <vxe-table-column field="item_cost" title="成本价" width="60" align="right" header-align="center"></vxe-table-column>
                      <vxe-table-column field="sex_flag" title="适合男女" width="60" align="center"></vxe-table-column>
                      <vxe-table-column field="emer_flag" title="允许急诊" width="60" align="center"></vxe-table-column>
                      <vxe-table-column field="comb_flag" title="组合项目" width="60" align="center"></vxe-table-column>
                      <vxe-table-column field="out_flag" title="外送项目" width="60" align="center"></vxe-table-column>
                      <vxe-table-column field="specimen_name" title="默认标本类型" width="80"></vxe-table-column>
                      <vxe-table-column field="itemclasscode" title="项目归类代码" width="80"></vxe-table-column>
                      <vxe-table-column field="itemclassname" title="项目归类名称" width="80"></vxe-table-column>
                      <vxe-table-column field="begindate" title="启用时间" width="80" align="center"></vxe-table-column>
                      <vxe-table-column field="enddate" title="停用时间" width="80" align="center"></vxe-table-column>
                      <vxe-table-column field="lastmodifydate" title="最后修改" width="80"></vxe-table-column>
                      <vxe-table-column field="refresh_log" title="同步备注信息" width="80"></vxe-table-column>
                      <vxe-table-column field="soap_docno" title="SOP文档编号" width="80"></vxe-table-column>
                      <vxe-table-column field="seq" title="序号" width="80" align="center"></vxe-table-column>
                      <vxe-table-column field="reqitemcode_reg" title="对应区域平台代码" width="80"></vxe-table-column>
                      <vxe-table-column field="collect_tips" title="标本采样说明" width="80"></vxe-table-column>
                      <vxe-table-column field="disabled" title="禁用" width="80"></vxe-table-column>
                      <vxe-table-column field="cxinputpatinfo" title="采血补充病人信息" width="80"></vxe-table-column>
                      <vxe-table-column field="singletube" title="单独采样标志" width="80" align="center"></vxe-table-column>
                      <vxe-table-column field="mincollectqty" title="最小采集量" width="80"></vxe-table-column>
                      <vxe-table-column field="tatnoholiday" title="TAT统计剔除节假日" width="80"></vxe-table-column>
                      <vxe-table-column field="specnum" title="标本取材数" width="80"></vxe-table-column>
                      <vxe-table-column field="specsmear" title="标本制片数" width="80"></vxe-table-column>
                      <vxe-table-column field="collectdictname" title="采样时间" width="80" align="center"></vxe-table-column>
                      <vxe-table-column field="infection_flag" title="院感项目" width="80" align="center"></vxe-table-column>
                      <vxe-table-column field="mintestinterval" title="最小检测间隔" width="80"></vxe-table-column>
                      <vxe-table-column field="externalcode1" title="外部代码1" width="80"></vxe-table-column>
                      <vxe-table-column field="externalcode2" title="外部代码2" width="80"></vxe-table-column>
                      <vxe-table-column field="externalcode3" title="外部代码3" width="80"></vxe-table-column>
                      <vxe-table-column field="reqitemgroups" title="自动编号归类" width="80"></vxe-table-column>
                      <vxe-table-column field="label_print_qty" title="标签份数" width="80"></vxe-table-column>
                      <vxe-table-column field="mixtypename" title="混样类型" width="80" align="center"></vxe-table-column>
                      <vxe-table-column field="nuclein_flagname" title="核酸项目" width="80" align="center"></vxe-table-column>
                      <vxe-table-column field="payinback_flagname" title="可手工补费" width="90" align="center"></vxe-table-column>
                  </vxe-table>
              </div>
              <template v-slot:fix>
                  <div>
                      <el-tabs @tab-click="handleTabClick" style="height: 100%" type="border-card">
                          <el-tab-pane label="基本信息">
                              <el-form :inline="true" :model="ReqItemRight" @submit.native.prevent label-width="auto" ref="form" class="border-firstcard">
                                  <table height="100%" width="100%" style="border-spacing: 5px 5px" class="tablelayout">
                                      <tr>
                                          <td width="100px">项目名称：</td>
                                          <td>
                                              <el-input v-model="ReqItemRight.req_itemname" readonly></el-input>
                                          </td>
                                          <td>LIS自建项目</td>
                                          <td>
                                              <el-checkbox label="" v-model="ReqItemRight.create_bylisflag" disabled></el-checkbox>
                                              TAT统计去除节假日
                                              <el-checkbox label="" v-model="ReqItemRight.tatnoholidayflag" disabled></el-checkbox>
                                          </td>
                                      </tr>
                                      <tr>
                                          <td>项目简称：</td>
                                          <td>
                                              <el-input v-model="ReqItemRight.req_itemna" readonly></el-input>
                                          </td>
                                          <td>项目英文名称</td>
                                          <td>
                                              <el-input v-model="ReqItemRight.req_itemname_en" readonly></el-input>
                                          </td>
                                      </tr>
                                      <tr>
                                          <td>项目归类：</td>
                                          <td>
                                              <el-input v-model="ReqItemRight.itemclassname" readonly></el-input>
                                          </td>
                                          <td>所属院区：</td>
                                          <td>
                                              <el-input v-model="ReqItemRight.hospitalname" readonly></el-input>
                                          </td>
                                      </tr>
                                      <tr>
                                          <td>项目代码(HIS)：</td>
                                          <td>
                                              <el-input v-model="ReqItemRight.his_itemcode" readonly></el-input>
                                          </td>
                                          <td>类别(HIS)：</td>
                                          <td>
                                              <el-input v-model="ReqItemRight.his_class" readonly></el-input>
                                          </td>
                                      </tr>
                                      <tr>
                                          <td>项目名称(HIS)：</td>
                                          <td>
                                              <el-input v-model="ReqItemRight.his_itemname" readonly></el-input>
                                          </td>
                                          <td>最小采集量：</td>
                                          <td>
                                              <el-input v-model="ReqItemRight.mincollectqty" readonly></el-input>
                                          </td>
                                      </tr>
                                      <tr>
                                          <td>执行申请项目：</td>
                                          <td>
                                              <el-input v-model="ReqItemRight.perform_deptname" readonly></el-input>
                                          </td>
                                          <td>拼音码：</td>
                                          <td>
                                              <el-input v-model="ReqItemRight.inputcode" readonly></el-input>
                                          </td>
                                      </tr>
                                      <tr>
                                          <td>单价：</td>
                                          <td>
                                              <el-input v-model="ReqItemRight.item_price" readonly></el-input>
                                          </td>
                                          <td>成本：</td>
                                          <td>
                                              <el-input v-model="ReqItemRight.item_cost" readonly></el-input>
                                          </td>
                                      </tr>
                                      <tr>
                                          <td>标签打印份数：</td>
                                          <td>
                                              <el-input v-model="ReqItemRight.label_print_qty" readonly></el-input>
                                          </td>
                                          <td>组合项目：</td>
                                          <td>
                                              <el-checkbox label="" v-model="ReqItemRight.comb_flagflag" disabled></el-checkbox>
                                              外送项目：
                                              <el-checkbox label="" v-model="ReqItemRight.out_flagflag" disabled></el-checkbox>
                                          </td>
                                      </tr>
                                      <tr>
                                          <td>适合性别：</td>
                                          <td>
                                              <el-input v-model="ReqItemRight.sex_flag" readonly></el-input>
                                          </td>
                                          <td>混样数：</td>
                                          <td>
                                              <el-input v-model="ReqItemRight.mixnum" readonly></el-input>
                                          </td>
                                      </tr>
                                      <tr>
                                          <td>是否急诊项目：</td>
                                          <td>
                                              <el-input v-model="ReqItemRight.emer_flag" readonly></el-input>
                                          </td>
                                          <td><span style="color: red">禁用</span>：</td>
                                          <td>
                                              <el-checkbox label="" v-model="ReqItemRight.disabledflag" disabled></el-checkbox>
                                              院感项目：
                                              <el-checkbox label="" v-model="ReqItemRight.infection_flagflag" disabled></el-checkbox>
                                          </td>
                                      </tr>
                                      <tr>
                                          <td>默认标本类型：</td>
                                          <td>
                                              <el-input v-model="ReqItemRight.specimen_name" readonly></el-input>
                                          </td>
                                          <td>采血时需补充电话、地址等信息</td>
                                          <td>
                                              <el-checkbox label="" v-model="ReqItemRight.cxinputpatinfoflag" disabled></el-checkbox>
                                              可手工补费：
                                              <el-checkbox label="" v-model="ReqItemRight.payinback_flag" disabled></el-checkbox>
                                          </td>
                                      </tr>
                                      <tr>
                                          <td>起始日期：</td>
                                          <td>
                                              <el-input v-model="ReqItemRight.begindate" readonly></el-input>
                                          </td>
                                          <td>截止日期：</td>
                                          <td>
                                              <el-input v-model="ReqItemRight.enddate" readonly></el-input>
                                          </td>
                                      </tr>
                                      <tr>
                                          <td>分单类别：</td>
                                          <td>
                                              <el-input v-model="ReqItemRight.req_groupname" readonly></el-input>
                                          </td>
                                          <td>SOAP文档 编号：</td>
                                          <td>
                                              <el-input v-model="ReqItemRight.soap_docno" readonly></el-input>
                                          </td>
                                      </tr>
                                      <tr>
                                          <td>标本采样说明：</td>
                                          <td>
                                              <el-input v-model="ReqItemRight.collect_tips" readonly></el-input>
                                          </td>
                                          <td>样本制备取材数：</td>
                                          <td>
                                              <el-input v-model="ReqItemRight.specnum" readonly></el-input>
                                          </td>
                                      </tr>
                                      <tr>
                                          <td>标本制备玻片数：</td>
                                          <td>
                                              <el-input v-model="ReqItemRight.specsmear" readonly></el-input>
                                          </td>
                                          <td>采样时间字典：</td>
                                          <td>
                                              <el-input v-model="ReqItemRight.collectdictname" readonly></el-input>
                                          </td>
                                      </tr>
                                      <tr>
                                          <td>最小间隔时间(分钟)：</td>
                                          <td>
                                              <el-input v-model="ReqItemRight.mintestinterval" readonly></el-input>
                                          </td>
                                          <td>自动编号归类:</td>
                                          <td>
                                              <el-input size="mini" v-model="ReqItemRight.reqitemgroups" readonly></el-input>
                                          </td>
                                      </tr>
                                      <tr>
                                          <td>外部代码1：</td>
                                          <td>
                                              <el-input v-model="ReqItemRight.externalcode1" readonly></el-input>
                                          </td>
                                          <td>外部代码2：</td>
                                          <td>
                                              <el-input v-model="ReqItemRight.externalcode2" readonly></el-input>
                                          </td>
                                      </tr>
                                      <tr>
                                          <td>外部代码3：</td>
                                          <td>
                                              <el-input v-model="ReqItemRight.externalcode3" readonly></el-input>
                                          </td>
                                          <td>混样类型</td>
                                          <td>
                                              <el-input v-model="ReqItemRight.mixtypename" readonly></el-input>
                                          </td>
                                      </tr>
                                      <tr>
                                          <td>同步备注信息：</td>
                                          <td>
                                              <el-input v-model="ReqItemRight.refresh_log" readonly></el-input>
                                          </td>
                                          <td>核酸项目：</td>
                                          <td>
                                              <el-checkbox label="" v-model="ReqItemRight.nuclein_flag" disabled></el-checkbox>
                                          </td>
                                      </tr>
                                  </table>
                              </el-form>
                          </el-tab-pane>
                          <el-tab-pane label="拆分规则">
                              <div ref="xTableDiv2" style="height: 100%">
                                  <vxe-table :data="tableDataDivide" :loading="loadingDivide" :keyboard-config="keyConfig" :keyboard-local-config="keyLocalConfig" :select-config="{ trigger: 'row' }" :sort-config="{ trigger: 'cell' }" :edit-config="{ trigger: 'click', mode: 'cell', showStatus: true }" :row-class-name="rowClassName" fit height="auto" header-align="center" highlight-current-row highlight-hover-row highlight-hover-column ref="xTable2" resizable show-header-overflow="tooltip" show-overflow="tooltip" size="mini" border stripe>
                                      <vxe-table-column field="div_req_itemcode" key="div_req_itemcode" title="拆分后项目" width="220px" sortable>
                                          <template v-slot="{ row }">
                                              <rm-ddl-common datatype="reqitem" dataname="申请项目" v-model="row.div_req_itemcode" width="200px" @change="divreqitemcodechange" key="1"></rm-ddl-common>
                                          </template>
                                      </vxe-table-column>
                                      <vxe-table-column field="specimen_code" key="specimen_code" title="标本类型" width="220px" sortable>
                                          <template v-slot="{ row }">
                                              <rm-ddl-common datatype="specimeno" dataname="标本类型" v-model="row.specimen_code" width="220px" key="2"></rm-ddl-common>
                                              <!-- <el-select v-model="row.specimen_code" placeholder="请选择">
                                                  <el-option v-for="item in OptionSpec" :key="item.specimen_code" :label="item.specimen_name" :value="item.specimen_code">
                                                  </el-option>
                                              </el-select> -->
                                          </template>
                                      </vxe-table-column>
                                      <vxe-table-column field="masterflag" key="masterflag" title="主项标识" width="80px" sortable align="center">
                                          <template v-slot="{ row }">
                                              <el-checkbox v-model="row.masterflag" true-label="1" false-label="0" @change="masterchange($event, row)"></el-checkbox>
                                          </template>
                                      </vxe-table-column>
                                      <vxe-table-column field="seq" key="seq" title="序号" width="80px" :edit-render="{ name: 'input', autoselect: true }" sortable></vxe-table-column>
                                  </vxe-table>
                              </div>
                          </el-tab-pane>
                          <el-tab-pane label="附加报告项目">
                              <div ref="xTableDiv3" style="height: 100%">
                                  <vxe-table :data="tableDataAddRpt" :loading="loadingAddRpt" :keyboard-config="keyConfig" :keyboard-local-config="keyLocalConfig" :select-config="{ trigger: 'row' }" :sort-config="{ trigger: 'cell' }" :edit-config="{ trigger: 'click', mode: 'cell', showStatus: true }" fit height="auto" header-align="center" highlight-current-row highlight-hover-row highlight-hover-column ref="xTable3" resizable show-header-overflow="tooltip" show-overflow="tooltip" size="mini" border stripe>
                                      <vxe-table-column field="seq" key="seq" title="序号" width="80px" :edit-render="{ name: 'input', autoselect: true }" sortable></vxe-table-column>
                                      <vxe-table-column field="rpt_itemcode" key="rpt_itemcode" title="附加报告项目" width="220px" sortable>
                                          <template v-slot="{ row }">
                                              <rm-ddl-rptitem prgno="MNG231" :germmode="false" v-model="row.rpt_itemcode" width="200px"></rm-ddl-rptitem>
                                          </template>
                                      </vxe-table-column>
                                      <vxe-table-column field="specimen_code" key="specimen_code" title="标本类型" width="140px" sortable>
                                          <template v-slot="{ row }">
                                              <rm-ddl-common datatype="specimen" dataname="标本类型" v-model="row.specimen_code" width="120px" key="3"></rm-ddl-common>
                                          </template>
                                      </vxe-table-column>
                                      <vxe-table-column field="inputlower" key="inputlower" title="可输入下限" width="80px" :edit-render="{ name: 'input', autoselect: true }" sortable></vxe-table-column>
                                      <vxe-table-column field="inputupper" key="inputupper" title="可输入上限" width="80px" :edit-render="{ name: 'input', autoselect: true }" sortable></vxe-table-column>
                                  </vxe-table>
                              </div>
                          </el-tab-pane>
                          <el-tab-pane label="互斥项目">
                              <div ref="xTableDiv8" style="height: 100%">
                                  <vxe-table :data="tableDataMutex" :loading="loadingMutex" :keyboard-config="keyConfig" :keyboard-local-config="keyLocalConfig" :select-config="{ trigger: 'row' }" :sort-config="{ trigger: 'cell' }" :edit-config="{ trigger: 'click', mode: 'cell', showStatus: true }" fit height="auto" header-align="center" highlight-current-row highlight-hover-row highlight-hover-column ref="xTable8" resizable show-header-overflow="tooltip" show-overflow="tooltip" size="mini" border stripe>
                                      <vxe-table-column field="mutex_itemcode" title="互斥项目" width="240px" sortable>
                                          <template v-slot="{ row }">
                                              <rm-ddl-common datatype="reqitem" dataname="申请项目" v-model="row.mutex_itemcode" @change="MutexChange" width="96%" key="4"></rm-ddl-common>
                                          </template>
                                      </vxe-table-column>
                                  </vxe-table>
                              </div>
                          </el-tab-pane>
                          <el-tab-pane label="标本类型">
                              <div ref="xTableDiv4" style="height: 100%">
                                  <vxe-table :data="tableDataSpec" :loading="loadingSpec" :keyboard-config="keyConfig" :keyboard-local-config="keyLocalConfig" :select-config="{ trigger: 'row' }" :sort-config="{ trigger: 'cell' }" :edit-config="{ trigger: 'click', mode: 'cell', showStatus: true }" fit height="auto" header-align="center" highlight-current-row highlight-hover-row highlight-hover-column ref="xTable4" resizable show-header-overflow="tooltip" show-overflow="tooltip" size="mini" border stripe>
                                      <vxe-table-column field="seq" key="seq" title="序号" width="80px" :edit-render="{ name: 'input', autoselect: true }" sortable></vxe-table-column>
                                      <vxe-table-column field="specimen_code" key="specimen_code" title="标本类型" width="140px" sortable>
                                          <template v-slot="{ row }">
                                              <rm-ddl-common datatype="specimen" dataname="标本类型" v-model="row.specimen_code" @change="SpecChange" width="120px" key="5"></rm-ddl-common>
                                          </template>
                                      </vxe-table-column>
                                  </vxe-table>
                              </div>
                          </el-tab-pane>
                          <el-tab-pane label="报告项目" v-if="lis113perauth">
                              <div ref="xTableDiv5" style="height: 100%">
                                  <vxe-table :data="tableDataRpt" :loading="loadingRpt" :keyboard-config="keyConfig" :keyboard-local-config="keyLocalConfig" :select-config="{ trigger: 'row' }" :sort-config="{ trigger: 'cell' }" :edit-config="{ trigger: 'click', mode: 'cell', showStatus: true }" fit height="auto" header-align="center" highlight-current-row highlight-hover-row highlight-hover-column ref="xTable5" resizable show-header-overflow="tooltip" show-overflow="tooltip" size="mini" border stripe>
                                      <vxe-table-column field="rpt_itemname" key="rpt_itemname" title="报告项目" width="160px" sortable></vxe-table-column>
                                      <vxe-table-column field="seq" key="seq" title="序号" width="60px" sortable></vxe-table-column>
                                      <vxe-table-column field="optional" key="optional" title="可选" width="60px" sortable align="center">
                                          <template v-slot="{ row }">
                                              <el-checkbox v-model="row.optional"></el-checkbox>
                                          </template>
                                      </vxe-table-column>
                                      <vxe-table-column field="externalcode1" key="externalcode1" title="外部代码1" width="100px" sortable></vxe-table-column>
                                      <vxe-table-column field="externalcode2" key="externalcode2" title="外部代码2" width="100px" sortable></vxe-table-column>
                                      <vxe-table-column field="externalcode3" key="externalcode3" title="外部代码3" width="100px" sortable></vxe-table-column>
                                  </vxe-table>
                              </div>
                          </el-tab-pane>
                          <el-tab-pane label="报告单元">
                              <div ref="xTableDiv6" style="height: 100%">
                                  <vxe-table :data="tableDataUnit" :loading="loadingUnit" :keyboard-config="keyConfig" :keyboard-local-config="keyLocalConfig" :edit-config="{ trigger: 'click', mode: 'cell', showStatus: true }" :select-config="{ trigger: 'row' }" :sort-config="{ trigger: 'cell' }" fit height="auto" header-align="center" highlight-current-row highlight-hover-row highlight-hover-column ref="xTable6" resizable show-header-overflow="tooltip" show-overflow="tooltip" size="mini" border stripe>
                                      <vxe-table-column :field="items.field" :key="items.field" :title="items.title" :width="items.width" sortable v-for="items in tableColumnUnit"> </vxe-table-column>
                                      <vxe-table-column field="rptunitid" key="rptunitid" title="报告单元" width="220px" sortable>
                                          <template v-slot="{ row }">
                                              <rm-ddl-rptunit v-model="row.rptunitid" :appendtobody="true" width="200px" :clearable="true"></rm-ddl-rptunit>
                                          </template>
                                      </vxe-table-column>
                                      <vxe-table-column key="defaultselect" field="defaultselect" title="默认" width="60px" align="center">
                                          <template v-slot="{ row, rowIndex }">
                                              <el-checkbox v-model="row.defaultselect"></el-checkbox>
                                          </template>
                                      </vxe-table-column>
                                      <vxe-table-column key="inputcode" field="inputcode" title="快速输入码" :edit-render="{ name: 'input', autoselect: true }" width="80px"> </vxe-table-column>
                                      <vxe-table-column key="sampleno1" field="sampleno1" title="起始样本号" :edit-render="{ name: 'input', autoselect: true }" width="120px"> </vxe-table-column>
                                      <vxe-table-column key="sampleno2" field="sampleno2" title="结束样本号" :edit-render="{ name: 'input', autoselect: true }" width="120px"> </vxe-table-column>
                                      <vxe-table-column key="sampleformat" field="sampleformat" title="样本号格式" :edit-render="{ name: 'input', autoselect: true }" width="120px"> </vxe-table-column>
                                      <vxe-table-column key="forbidinput" field="forbidinput" title="禁止手工输入" width="80px" align="center">
                                          <template v-slot="{ row, rowIndex }">
                                              <el-checkbox v-model="row.forbidinput"></el-checkbox>
                                          </template>
                                      </vxe-table-column>
                                      <vxe-table-column key="weekdays" field="weekdays" title="周几检验" :edit-render="{ name: 'input' }" width="80px"></vxe-table-column>
                                      <vxe-table-column key="reqitemgroup" field="reqitemgroup" title="分组" width="50px">
                                          <template v-slot="{ row }">
                                              <el-select v-model="row.reqitemgroup">
                                                  <el-option value="A" label="A"></el-option>
                                                  <el-option value="B" label="B"></el-option>
                                                  <el-option value="C" label="C"></el-option>
                                                  <el-option value="D" label="D"></el-option>
                                                  <el-option value="E" label="E"></el-option>
                                                  <el-option value="F" label="F"></el-option>
                                              </el-select>
                                          </template>
                                      </vxe-table-column>
                                      <vxe-table-column key="endtime" field="endtime" title="当日截止时间" :edit-render="{ name: 'input' }" width="210px">
                                          <template v-slot:edit="{ row }">
                                              <el-input style="width: 100%" @focus="setendtime($event, row)" v-model="row.endtime" placeholder="请输入截止时间" clearable="" :readonly="true"></el-input>
                                          </template>
                                      </vxe-table-column>
                                      <vxe-table-column key="specialreqitem" field="specialreqitem" title="特别关注" width="60px" align="center">
                                          <template v-slot="{ row, rowIndex }">
                                              <el-checkbox v-model="row.specialreqitem"></el-checkbox>
                                          </template>
                                      </vxe-table-column>
                                  </vxe-table>
                              </div>
                          </el-tab-pane>
                          <el-tab-pane label="采集部位">
                              <div ref="xTableDiv7" style="height: 100%">
                                  <vxe-table :data="tableDataCollect" :loading="loadingCollect" :keyboard-config="keyConfig" :keyboard-local-config="keyLocalConfig" :select-config="{ trigger: 'row' }" :sort-config="{ trigger: 'cell' }" :edit-config="{ trigger: 'click', mode: 'cell', showStatus: true }" fit height="auto" header-align="center" highlight-current-row highlight-hover-row highlight-hover-column ref="xTable7" resizable show-header-overflow="tooltip" show-overflow="tooltip" size="mini" border stripe>
                                      <vxe-table-column field="specimen_code" title="标本类型" width="120px" sortable>
                                          <template v-slot="{ row }">
                                              <rm-ddl-common datatype="specimen" dataname="标本类型" v-model="row.specimen_code" width="120px" key="6"></rm-ddl-common>
                                          </template>
                                      </vxe-table-column>
                                      <vxe-table-column field="collectionpoint" title="采集部位" width="120px" sortable>
                                          <template v-slot="{ row }">
                                              <rm-ddl-common datatype="seccode" kindno="collectionpoint" v-model="row.collectionpoint" width="120px" key="7"></rm-ddl-common>
                                          </template>
                                      </vxe-table-column>
                                      <vxe-table-column field="seq" title="序号" width="80px" sortable></vxe-table-column>
                                  </vxe-table>
                              </div>
                          </el-tab-pane>
                          <el-tab-pane label="计划维护">
                              <div ref="xTableDiv9" style="height: 100%">
                                  <vxe-table show-overflow ref="xTable9" class="mytable-style" height="auto" :loading="loadingPlan" :sort-config="{ trigger: 'cell' }" :keyboard-config="keyConfig" :mouse-config="{ selected: true }" :keyboard-local-config="keyLocalConfig" :data.sync="tableDataPlan" border size="mini" show-header-overflow highlight-current-row :select-config="{ reserve: true }" highlight-hover-row resizable stripe :edit-config="{ trigger: 'click', mode: 'cell', showStatus: true, showIcon: false }" header-align="center">
                                      <vxe-table-column field="bitemselect" title="" width="30" header-align="center" align="center">
                                          <template v-slot="{ row }">
                                              <el-checkbox v-model="row.bitemselect" true-label="1" false-label="0"> </el-checkbox>
                                          </template>
                                      </vxe-table-column>
                                      <vxe-table-column field="plan_id" title="计划ID" align="center" width="50" sortable></vxe-table-column>
                                      <vxe-table-column field="plan_code" title="计划代码" width="70" sortable> </vxe-table-column>
                                      <vxe-table-column field="plan_name" title="计划名称" width="220" sortable> </vxe-table-column>
                                      <vxe-table-column field="event_sourcename" title="触发动作" width="100" sortable> </vxe-table-column>
                                      <vxe-table-column field="event_source1name" title="补充触发动作" width="100" sortable> </vxe-table-column>
                                      <vxe-table-column field="event_destname" title="后续动作" width="100" sortable> </vxe-table-column>
                                      <vxe-table-column field="hospname" title="操作医院" align="center" width="200" sortable> </vxe-table-column>
                                      <vxe-table-column field="perform_deptsname" title="执行科室" width="120" sortable> </vxe-table-column>
                                  </vxe-table>
                              </div>
                          </el-tab-pane>
                      </el-tabs>
                  </div>
              </template>
          </rm-layout-right>
      </div>
      <!-- top="4vh height="600px"" -->
      <el-dialog v-el-drag-dialog :close-on-click-modal="false" :title="dialogTitle" :visible.sync="dialogFormVisible" width="800px" height="3000px" v-if="dialogFormVisible">
          <div>
              <el-form :inline="true" :model="ReqItem" @submit.native.prevent label-width="auto" ref="form">
                  <table height="100%" width="100%" style="width: 100%" class="tablelayout" ref="inputtable">
                      <tr>
                          <td style="color: red">项目代码：</td>
                          <td style="width: 260px" colspan="3">
                              <el-input size="mini" v-model="ReqItem.req_itemcode" ref="autofocus1" @keyup.enter.native="Funautofocus(1)"></el-input>
                          </td>
                      </tr>
                      <tr>
                          <td style="color: red">项目名称：</td>
                          <td style="width: 260px" colspan="3">
                              <el-input size="mini" v-model="ReqItem.req_itemname" @input="NameInput" @change="NameChange" ref="autofocus2" @keyup.enter.native="Funautofocus(2)"></el-input>
                          </td>
                      </tr>
                      <tr>
                          <td style="color: red">项目简称：</td>
                          <td>
                              <el-input size="mini" v-model="ReqItem.req_itemna" ref="autofocus3" @keyup.enter.native="Funautofocus(3)"></el-input>
                          </td>
                          <td style="text-align: left">
                              <el-checkbox label="LIS自建项目" v-model="ReqItem.create_bylis" ref="autofocus4" @keyup.enter.native="Funautofocus(4)"></el-checkbox>
                              <!--el-checkbox label="输血科收费项" v-model="ReqItem.sysno" ref="autofocus444" v-if="isbis"></el-checkbox-->
                              <el-checkbox v-model="ReqItem.sysno" true-label="BLD" false-label="LIS" v-if="isbis">输血科收费项</el-checkbox>
                          </td>
                          <td>
                              <el-checkbox label="TAT统计去除节假日" v-model="ReqItem.tatnoholiday"></el-checkbox>
                          </td>
                      </tr>
                      <tr>
                          <td>项目英文名称：</td>
                          <td style="width: 260px" colspan="3">
                              <el-input size="mini" v-model="ReqItem.req_itemname_en" ref="autofocus5" @keyup.enter.native="Funautofocus(5)"></el-input>
                          </td>
                      </tr>
                      <tr>
                          <td>项目归类：</td>
                          <td>
                              <!-- <el-input size="mini" v-model="ReqItem.itemclasscode" ref="autofocus6" @keyup.enter.native="Funautofocus(6)" :key="1"></el-input> -->
                              <rm-ddl-reqitemclass v-model="ReqItem.itemclasscode" width="255px" ref="autofocus6" @keyup.enter.native="Funautofocus(6)" :key="1"></rm-ddl-reqitemclass>
                          </td>
                          <td>所属院区：</td>
                          <td>
                              <rm-ddl-common datatype="hospital" :appendtobody="true" dataname="医院" v-model="ReqItem.hospcode" ref="autofocus7" @keyup.enter.native="Funautofocus(7)" :disabled="IsAreaMode && $tool.getSession($tool.loginutype) != 'G'" key="8"></rm-ddl-common>
                          </td>
                      </tr>
                      <tr>
                          <td>项目代码(HIS)：</td>
                          <td>
                              <el-input size="mini" v-model="ReqItem.his_itemcode" disabled ref="autofocus8" @keyup.enter.native="Funautofocus(8)"></el-input>
                          </td>
                          <td>类别(HIS)：</td>
                          <td>
                              <el-input size="mini" v-model="ReqItem.his_class" disabled ref="autofocus9" @keyup.enter.native="Funautofocus(9)"></el-input>
                          </td>
                      </tr>
                      <tr>
                          <td>项目名称(HIS)：</td>
                          <td>
                              <el-input size="mini" v-model="ReqItem.his_itemname" disabled ref="autofocus10" @keyup.enter.native="Funautofocus(10)"></el-input>
                          </td>
                          <td>最小采集量：</td>
                          <td>
                              <el-input size="mini" v-model="ReqItem.mincollectqty" ref="autofocus11" @keyup.enter.native="Funautofocus(11)"></el-input>
                          </td>
                      </tr>
                      <tr>
                          <td>执行申请项目：</td>
                          <td>
                              <rm-ddl-common datatype="dept" dataname="申请项目" :appendtobody="true" v-model="ReqItem.perform_dept" ref="autofocus12" @keyup.enter.native="Funautofocus(12)" width="100%" key="9"></rm-ddl-common>
                          </td>
                          <td>拼音码：</td>
                          <td>
                              <el-input size="mini" v-model="ReqItem.inputcode" ref="autofocus13" @keyup.enter.native="Funautofocus(13)"></el-input>
                          </td>
                      </tr>
                      <tr>
                          <td>单价：</td>
                          <td>
                              <table style="border-spacing: 0px; padding: 0px">
                                  <tr>
                                      <td width="40px">
                                          <el-input size="mini" v-model="ReqItem.item_price" ref="autofocus14" @keyup.enter.native="Funautofocus(14)"></el-input>
                                      </td>
                                      <td style="padding: 0px; margin: 0px; width: 15px; text-align: right">成本：</td>
                                      <td style="width: 43%">
                                          <el-input size="mini" v-model="ReqItem.item_cost" ref="autofocus15" @keyup.enter.native="Funautofocus(15)"></el-input>
                                      </td>
                                  </tr>
                              </table>
                          </td>
                          <td>标签打印份数：</td>
                          <td>
                              <el-input size="mini" v-model="ReqItem.label_print_qty" ref="autofocus16" @keyup.enter.native="Funautofocus(16)"></el-input>
                          </td>
                      </tr>
                      <tr>
                          <td>适合性别：</td>
                          <td>
                              <el-radio-group v-model="ReqItem.sex_flag">
                                  <el-radio label="男性" ref="autofocus17" @keyup.enter.native="Funautofocus(17)"></el-radio>
                                  <el-radio label="女性"></el-radio>
                                  <el-radio label="全部"></el-radio>
                              </el-radio-group>
                          </td>
                          <td colspan="2">
                              <table style="border-spacing: 0px; padding: 0px; width: 100%">
                                  <tr>
                                      <td style="text-align: left; width: 24%">
                                          <el-checkbox label="组合项目" v-model="ReqItem.comb_flag" ref="autofocus18" @keyup.enter.native="Funautofocus(18)"></el-checkbox>
                                      </td>
                                      <td style="text-align: left; width: 24%">
                                          <el-checkbox label="外送项目" v-model="ReqItem.out_flag" ref="autofocus19" @keyup.enter.native="Funautofocus(19)"></el-checkbox>
                                      </td>
                                      <td style="text-align: left">
                                          <el-checkbox label="禁用" v-model="ReqItem.disabled" ref="autofocus20" @keyup.enter.native="Funautofocus(20)"></el-checkbox>
                                      </td>
                                      <td>
                                          <el-checkbox label="院感项目" v-model="ReqItem.infection_flag" ref="autofocus34" @keyup.enter.native="Funautofocus(34)"></el-checkbox>
                                      </td>
                                  </tr>
                              </table>
                          </td>
                      </tr>
                      <tr>
                          <td>是否急诊项目：</td>
                          <td>
                              <el-radio-group v-model="ReqItem.emer_flag">
                                  <el-radio label="常规" ref="autofocus21" @keyup.enter.native="Funautofocus(21)"></el-radio>
                                  <el-radio label="急诊"></el-radio>
                                  <el-radio label="全部"></el-radio>
                              </el-radio-group>
                          </td>
                          <td style="text-align: left">
                              <el-checkbox label="采血时需补充电话、地址等信息" v-model="ReqItem.cxinputpatinfo" ref="autofocus22" @keyup.enter.native="Funautofocus(22)"></el-checkbox>
                          </td>
                          <td>
                              <el-checkbox label="可手工补费" v-model="ReqItem.payinback_flag" ref="autofocus44" @keyup.enter.native="Funautofocus(44)"></el-checkbox>
                              <el-checkbox label="核酸项目" v-model="ReqItem.nuclein_flag" ref="autofocus43" @keyup.enter.native="Funautofocus(43)"></el-checkbox>
                          </td>
                      </tr>
                      <tr>
                          <td>默认标本类型：</td>
                          <td>
                              <rm-ddl-common datatype="specimen" dataname="标本类型" :appendtobody="true" v-model="ReqItem.specimen_code" ref="autofocus23" @keyup.enter.native="Funautofocus(23)" width="100%" key="10"></rm-ddl-common>
                          </td>
                          <td>起始日期：</td>
                          <td>
                              <el-date-picker v-model="ReqItem.begindate" type="date" placeholder="选择日期" ref="autofocus24" @keydown.enter.native="Funautofocus(24)" style="width: 100%"> </el-date-picker>
                          </td>
                      </tr>
                      <tr>
                          <td>分单类别：</td>
                          <td>
                              <el-input style="position: absolute; z-index: -99; width: 0px" ref="autofocus25" @keyup.enter.native="Funautofocus(25)"></el-input>
                              <rm-ddl-common datatype="reqgroup" dataname="分单类别" v-model="ReqItem.req_groupid" :appendtobody="true" ref="autofocus26" @keyup.enter.native="Funautofocus(26)" width="100%" key="11"></rm-ddl-common>
                          </td>
                          <td>截止日期：</td>
                          <td>
                              <el-date-picker v-model="ReqItem.enddate" type="date" placeholder="选择日期" ref="autofocus27" @keydown.enter.native="Funautofocus(27)" style="width: 100%"> </el-date-picker>
                          </td>
                      </tr>
                      <tr>
                          <td>最后修改：</td>
                          <td>
                              <el-input style="position: absolute; z-index: -99; width: 0px" ref="autofocus28" @keyup.enter.native="Funautofocus(28)"></el-input>
                              <el-input size="mini" v-model="ReqItem.lastmodifydate" disabled ref="autofocus29" @keyup.enter.native="Funautofocus(29)"></el-input>
                          </td>
                          <td>SOAP文档 编号：</td>
                          <td>
                              <el-input size="mini" v-model="ReqItem.soap_docno" ref="autofocus30" @keyup.enter.native="Funautofocus(30)"></el-input>
                          </td>
                      </tr>
                      <tr>
                          <td>标本采样说明：</td>
                          <td>
                              <el-input size="mini" v-model="ReqItem.collect_tips" ref="autofocus31" @keyup.enter.native="Funautofocus(31)"></el-input>
                          </td>
                          <td>样本制备取材数：</td>
                          <td>
                              <el-input size="mini" v-model="ReqItem.specnum" ref="autofocus32" @keyup.enter.native="Funautofocus(32)"></el-input>
                          </td>
                      </tr>
                      <tr>
                          <td>标本制备玻片数：</td>
                          <td>
                              <el-input size="mini" v-model="ReqItem.specsmear" ref="autofocus33" @keyup.enter.native="Funautofocus(33)"></el-input>
                          </td>
                          <td>采样时间字典：</td>
                          <td>
                              <rm-ddl-common datatype="collectdict" dataname="采样时间" v-model="ReqItem.collectdictid" :appendtobody="true" ref="autofocus34" @keyup.enter.native="Funautofocus(34)" width="100%" key="12"></rm-ddl-common>
                              <!-- <el-input size="mini" v-model="ReqItem.collectdictid" ref="autofocus32" @keyup.enter.native="Funautofocus('autofocus32')"></el-input> -->
                          </td>
                      </tr>
                      <tr>
                          <td>最小间隔时间(分钟)：</td>
                          <td>
                              <el-input size="mini" v-model="ReqItem.mintestinterval" ref="autofocus35" @keyup.enter.native="Funautofocus(35)"></el-input>
                          </td>
                          <td>自动编号归类:</td>
                          <td>
                              <el-input size="mini" v-model="ReqItem.reqitemgroups" placeholder="建议输入两位字母" ref="autofocus36" @keyup.enter.native="Funautofocus(36)"></el-input>
                          </td>
                      </tr>
                      <tr>
                          <td>外部代码1：</td>
                          <td>
                              <el-input size="mini" v-model="ReqItem.externalcode1" ref="autofocus37" @keyup.enter.native="Funautofocus(37)"></el-input>
                          </td>
                          <td>外部代码2：</td>
                          <td>
                              <el-input size="mini" v-model="ReqItem.externalcode2" ref="autofocus38" @keyup.enter.native="Funautofocus(38)"></el-input>
                          </td>
                      </tr>
                      <tr>
                          <td>外部代码3：</td>
                          <td>
                              <el-input size="mini" v-model="ReqItem.externalcode3" ref="autofocus39" @keyup.enter.native="Funautofocus(39)"></el-input>
                          </td>
                          <td>混样数：</td>
                          <td>
                              <el-input size="mini" v-model="ReqItem.mixnum" ref="autofocus40" @keyup.enter.native="Funautofocus(40)"></el-input>
                          </td>
                      </tr>
                      <tr>
                          <td>混样类型：</td>
                          <td colspan="3">
                              <rm-ddl-common datatype="seccode" kindno="REQITEMMIXTYPECODE" dataname="混样类型" v-model="ReqItem.mixtypecode" :appendtobody="true" ref="autofocus41" @keyup.enter.native="Funautofocus(41)" width="100%" key="13"></rm-ddl-common>
                          </td>
                      </tr>
                      <tr>
                          <td style="vertical-align: top">同步备注信息：</td>
                          <td colspan="3">
                              <el-input type="textarea" v-model="ReqItem.refresh_log" ref="autofocus42" @keyup.enter.native="Funautofocus(42)" maxlength="80" show-word-limit></el-input>
                          </td>
                      </tr>
                  </table>
              </el-form>
              <div class="dialog-footer" slot="footer" style="text-align: right">
                  <table style="width: 100%">
                      <tr>
                          <td width="630"></td>
                          <td>
                              <el-button @click="CommitTips()">确 定</el-button>
                          </td>
                          <td>
                              <el-button @click="CancelTips()">取 消</el-button>
                          </td>
                      </tr>
                  </table>
              </div>
          </div>
      </el-dialog>

      <el-dialog v-el-drag-dialog :close-on-click-modal="false" title="提示" :visible.sync="dialogVisible" width="30%">
          <div class="el-message-box__status el-icon-warning"></div>
          <div class="el-message-box__message" style="padding-top: 24px">
              <p>
                  确定要删除申请项目<b style="color: red">{{ DelReqName }}</b>吗?
              </p>
          </div>
          <span slot="footer" class="dialog-footer">
              <el-button @click="CommitTips()">确 定</el-button>
              <el-button @click="CancelTips()">取 消</el-button>
          </span>
      </el-dialog>

      <el-dialog v-el-drag-dialog :close-on-click-modal="false" title="设置截止时间" :visible.sync="endtimedialogForm" width="350px" height="200px">
          <el-form :inline="true" @submit.native.prevent label-width="auto" ref="form1" style="border: 1px solid #ccc">
              <table>
                  <tr>
                      <td>工作日截止时间</td>
                      <td>
                          <el-time-picker v-model="workday_endtime" placeholder="任意时间点" value-format="HH:mm" format="HH:mm" style="width: 100%"></el-time-picker>
                      </td>
                  </tr>
                  <tr>
                      <td>周末截止时间</td>
                      <td>
                          <el-time-picker v-model="weekend_endtime" placeholder="任意时间点" value-format="HH:mm" format="HH:mm" style="width: 100%"></el-time-picker>
                      </td>
                  </tr>
                  <tr>
                      <td>节假日截止时间</td>
                      <td>
                          <el-time-picker v-model="holiday_endtime" placeholder="任意时间点" value-format="HH:mm" format="HH:mm" style="width: 100%"></el-time-picker>
                      </td>
                  </tr>
              </table>
          </el-form>
          <div style="text-align: right; padding-top: 5px">
              <el-button type="primary" @click="CommitEndtime()">确定</el-button>
              <el-button @click="endtimedialogForm = false">取消</el-button>
          </div>
      </el-dialog>

      <el-dialog v-el-drag-dialog width="1000px" top="10px" :append-to-body="true" :close-on-click-modal="false" title="新增申请项目对照报告项目" :visible.sync="dialogTableVisible1">
          <rm-pop-selrptitem @cancel="dialogTableVisible1 = false" @selitem="addrptitem"></rm-pop-selrptitem>
      </el-dialog>

      <!--导出列选择-->
      <el-dialog title="导出列选择" :visible.sync="chooseColumndialogVisible" width="380px" v-el-drag-dialog :close-on-click-modal="false" v-if="chooseColumndialogVisible">
          <rm-excolsetting :excolPro="excolPro" :allTableCol="allTableCol" @change="saveExportColumn" ref="excolset"></rm-excolsetting>
      </el-dialog>
      <rm-excolsetting :excolPro="excolPro" :allTableCol="allTableCol" @change="saveExportColumn" ref="excolset" v-show="false"></rm-excolsetting>
      <!--多选弹窗--->
      <el-dialog width="900px" v-el-drag-dialog :append-to-body="true" :close-on-click-modal="false" :title="multichktitle" :visible.sync="dialogMultipleVisible" :destroy-on-close="true">
          <rm-SqlMultiple :leftOption="option1" :rightOption="option2" :name="fieldname" @change="closedialog"></rm-SqlMultiple>
      </el-dialog>
  </div>
</template>

<script>
import rmDdlCommon from "../../../rmcompents/rm-ddl-common.vue";
import RmExcolsetting from "@/components/rmcompents/rm_excolsetting.vue";
export default {
  components: { rmDdlCommon },
  name: "MNG231",
  components: { RmExcolsetting },
  data() {
      return {
          searchtext: "",
          reqgroupval: "",
          IsAreaMode: false,
          curtabindex: 0,
          // buttonwidth: "",
          actionflag: 0,
          masterflag: 0,
          isshow: true,
          loading: false,
          loadingDivide: false,
          loadingAddRpt: false,
          loadingRpt: false,
          loadingSpec: false,
          loadingUnit: false,
          loadingPlan: false,
          loadingCollect: false,
          isbis: false,
          loadingMutex: false, //互斥项目
          keyConfig: {
              isDel: true,
              isTab: true,
              isEdit: true,
          },
          keyLocalConfig: {
              isArrow: true,
          },
          tableColumn: [],
          tableColumnDivide: [],
          tableColumnUnit: [],
          tableData: [],
          tableTempData: [],
          tableDataDivide: [],
          tableDataAddRpt: [],
          tableDataSpec: [],
          tableDataMutex: [], //互斥项目
          tableDataRpt: [],
          tableDataUnit: [],
          tableDataPlan: [],
          tableDataCollect: [],
          tableCopyData: [],
          AddArray: "",
          // OptionSpec: [],

          ReqItemRight: {},
          ReqItem: {},
          OldReqItem: {},
          DelReqName: "",
          tempRowIndex: 0,
          DelIndex: -1,

          dialogTitle: "",
          dialogFormVisible: false,
          dialogTableVisible1: false,
          dialogVisible: false,
          DivideFirst: true,
          AddRptFirst: true,
          SpecFirst: true,
          RptFirst: true,
          FirstLoading: true,
          disabledflag: 0,
          onlyshow: false,
          editvisible: true,
          recordvisible: false,
          savevisible: false,
          copyvisible: false,
          syncvisible: true,
          mastercode: "",
          rptunitendtimeuseflag: false,
          rptunitendtime: "",
          endtime_row: {},
          endtime_code: {},
          workday_endtime: "",
          weekend_endtime: "",
          holiday_endtime: "",
          endtimedialogForm: false,
          endtime_row: {},
          endtime_code: {},
          usertype: "",
          isused: false,
          //导出
          excolPro: "mng231",
          allTableCol: [],
          chooseColumndialogVisible: false,
          option1: [],
          option2: [],
          fieldname: "",
          multichktitle: "",
          dialogMultipleVisible: false,
          searchitemclasscode: "",
          searchcollectdictid: "",
          searchitem_price1: "",
          searchitem_price2: "",
          searchoutflag: "0",
          lis113perauth: false,
          LIS113addauth: false,
          LIS113modauth: false,
          LIS113delauth: false,
      };
  },
  computed: {
      list() {
          let filterName = this.searchtext.trim();
          if (filterName) {
              let num = this.AddArray;
              let rest = this.tableData.filter((item) => {
                  return item.req_itemcode.toUpperCase().indexOf(filterName.toUpperCase()) > -1 || (item.inputcode ? item.inputcode.toUpperCase().indexOf(filterName.toUpperCase()) > -1 : false) || (item.req_itemname ? item.req_itemname.toUpperCase().indexOf(filterName.toUpperCase()) > -1 : false) || (item.req_itemna ? item.req_itemna.toUpperCase().indexOf(filterName.toUpperCase()) > -1 : false) || (item.his_itemcode ? item.his_itemcode.toUpperCase().indexOf(filterName.toUpperCase()) > -1 : false) || item.req_itemcode == num;
              });
              return rest;
          } else {
              return this.tableData;
          }
      },
  },
  watch: {
      searchtext(val) {
          if (this.AddArray != "") {
              this.AddArray = "";
          }
          this.$nextTick(() => {
              var row = this.$refs.xTable.getCurrentRow();
              if (this.$refs.xTable.tableData.length > 0) row = this.$refs.xTable.tableData[0];
              if (row.req_itemcode) {
                  this.$refs.xTable.setCurrentRow(row);
                  if (row.hospcode.toUpperCase() == "ALL" && this.IsAreaMode && this.usertype != "G") {
                      this.isused = true;
                  } else {
                      this.isused = false;
                  }
                  this.ReqItemRight = row;
                  this.DelReqName = row.req_itemname;
                  this.SetReqItemRightFlag();
                  this.tempRowIndex = this.$refs.xTable.getRowIndex(row);
                  this.ShowTabByTabindex(this.curtabindex);
              }
          });
      },
      "ReqItem.req_itemna": {
          handler(val) {
              if (val) {
                  //当前字符串的字节数
                  var strlen = 0;
                  //用来做字符串截取的下标
                  var index = 0;
                  //限制的最大输入长度
                  var max = 32;

                  for (var i = 0; i < val.length; i++) {
                      if (strlen > max) {
                          //输入长度超标的提示
                          //this.msgError("产品编号长度不能超过100个长度(英文，数字各占一个长度，中文占两个长度");
                          break;
                      }
                      index = i + 1;
                      //判别是中文字符还是英文字符的方法
                      if (val.charCodeAt(i) < 27 || val.charCodeAt(i) > 126) {
                          //中文和中文字符
                          strlen += 2;
                      } else {
                          strlen++;
                      }
                  }
                  // 自动截掉多余的字符。保留之前的限制内的字符长度
                  if (strlen > max) {
                      this.ReqItem.req_itemna = val.substr(0, index - 1);
                  } else {
                      this.ReqItem.req_itemna = val.substr(0, index);
                  }
              }
          },
      },
  },
  created() {
      this.isbis = this.$tool.checkBis();
      this.InitPageData();
  },
  mounted() {
      this.$refs.excolset.colSettingToDB();
  },
  updated() {
      // this.getButtonWidth();
      if (this.FirstLoading) {
          var selectrow = {};
          if (this.AddArray > 0) {
              selectrow = this.$refs.xTable.tableData.filter((item) => {
                  return item.req_itemcode == this.AddArray;
              })[0];
          } else {
              if (this.tempRowIndex > 0) selectrow = this.$refs.xTable.getData(this.tempRowIndex);
              else selectrow = this.$refs.xTable.getData(0);
          }
          if (selectrow) {
              this.FirstLoading = false;
              this.$nextTick(() => {
                  if (selectrow.hospcode.toUpperCase() == "ALL" && this.IsAreaMode && this.usertype != "G") {
                      this.isused = true;
                  } else {
                      this.isused = false;
                  }
                  this.$refs.xTable.setCurrentRow(selectrow);
                  this.ReqItemRight = selectrow;
                  this.DelReqName = selectrow.req_itemname;
                  this.SetReqItemRightFlag();
                  this.$refs.xTable.scrollToRow(selectrow);
              });
          }
      }
  },
  methods: {
      currentChangeEvent({ row }) {
          if (row.hospcode.toUpperCase() == "ALL" && this.IsAreaMode && this.usertype != "G") {
              this.isused = true;
          } else {
              this.isused = false;
          }
          this.ReqItemRight = row;
          this.SetReqItemRightFlag();
          this.DelReqName = row.req_itemname;
          this.tempRowIndex = this.$refs.xTable.getRowIndex(row);
          this.ShowTabByTabindex(this.curtabindex);
          this.tableDataPlan = [];
      },
      // getButtonWidth() {
      //     if (this.$refs.buttondiv) {
      //         this.buttonwidth = this.$refs.buttondiv.offsetWidth + "px";
      //     }
      // },
      SetReqItemRightFlag() {
          this.ReqItemRight.create_bylisflag = this.ReqItemRight.create_bylis == "是";
          //   this.ReqItemRight.sysno = this.ReqItemRight.sysno == "是";
          this.ReqItemRight.tatnoholidayflag = this.ReqItemRight.tatnoholiday == "是";
          this.ReqItemRight.comb_flagflag = this.ReqItemRight.comb_flag == "是";
          this.ReqItemRight.out_flagflag = this.ReqItemRight.out_flag == "是";
          this.ReqItemRight.disabledflag = this.ReqItemRight.disabled == "是";
          this.ReqItemRight.cxinputpatinfoflag = this.ReqItemRight.cxinputpatinfo == "是";
          this.ReqItemRight.infection_flagflag = this.ReqItemRight.infection_flag == "是";
          this.ReqItemRight.nuclein_flag = this.ReqItemRight.nuclein_flagname == "是";
          this.ReqItemRight.payinback_flag = this.ReqItemRight.payinback_flagname == "是";
      },
      ShowTabByTabindex(curtabindex) {
          switch (curtabindex) {
              case 1:
                  this.ShowDivide();
                  break;
              case 2:
                  this.ShowAddRptitem();
                  break;
              case 3:
                  this.ShowSpec();
                  break;
              case 4:
                  this.ShowRptitem();
                  break;
              case 5:
                  this.ShowUnit();
                  break;
              case 6:
                  this.ShowCollect();
                  break;
              case 7:
                  this.ShowMutex();
                  break;
              case 8:
                  this.ShowPlan();
                  break;
          }
      },
      rowClassName({ row, rowIndex }) {},
      handleTabClick(tab, event) {
          let isBaseInfoFlag = true;
          let copyvisibleFlag = false;
          if (tab.label != "基本信息") {
              isBaseInfoFlag = false;
              switch (tab.label) {
                  case "拆分规则":
                      this.curtabindex = 1;
                      if (this.DivideFirst) {
                          this.ShowDivide();
                          this.DivideFirst = false;
                      }
                      break;
                  case "附加报告项目":
                      this.curtabindex = 2;
                      if (this.AddRptFirst) {
                          this.ShowAddRptitem();
                          this.AddRptFirst = false;
                      }
                      break;
                  case "标本类型":
                      this.curtabindex = 3;
                      if (this.SpecFirst) {
                          this.ShowSpec();
                          this.SpecFirst = false;
                      }
                      break;
                  case "报告项目":
                      this.curtabindex = 4;
                      if (this.RptFirst) {
                          this.ShowRptitem();
                          this.RptFirst = false;
                      }
                      copyvisibleFlag = true;
                      break;
                  case "报告单元":
                      this.curtabindex = 5;
                      this.ShowUnit();
                      break;
                  case "采集部位":
                      this.curtabindex = 6;
                      this.ShowCollect();
                      break;
                  case "互斥项目":
                      this.curtabindex = 7;
                      this.ShowMutex();
                      break;
                  case "计划维护":
                      this.curtabindex = 8;
                      this.ShowPlan();
                      break;
              }
          }
          this.editvisible = isBaseInfoFlag;
          this.recordvisible = !isBaseInfoFlag;
          this.savevisible = !isBaseInfoFlag;
          this.copyvisible = copyvisibleFlag;
          this.syncvisible = isBaseInfoFlag;
          //设置按钮显隐
          if (tab.label == "计划维护") {
              this.recordvisible = false;
          }
      },
      InitPageData() {
          this.InitPage();
          this.ShowMain();
      },
      InitPage() {
          this.$tool
              .request({
                  url: "MNG/MNG2/MNG231",
                  method: "post",
                  data: {
                      action: "initPage",
                  },
              })
              .then((res) => {
                  this.lis113perauth = res.lis113perauth == "1"; //LIS113功能权限
                  this.LIS113addauth = res.LIS113addauth == "1"; //新增明细按钮权限根据LIS113新增权限
                  this.LIS113modauth = res.LIS113modauth == "1"; //LIS113修改权限
                  this.LIS113delauth = res.LIS113delauth == "1"; //删除明细按钮权限根据LIS113删除权限
              })
              .catch((e) => {
                  this.$alert("出错啦！" + e, "提示");
              });
      },
      OpenDialog(flag) {
          if (flag == 1) {
              var date = new Date();
              var now = date.getFullYear() + "-" + (date.getMonth() + 1) + "-" + date.getDate();
              var end = "2099-12-31";
              this.dialogTitle = "新增申请项目字典";
              this.actionflag = flag;
              this.ReqItem = { create_bylis: true, begindate: now, enddate: end, hospcode: this.$tool.getSession(this.$tool.selectedhis), req_itemna: "" };
              this.dialogFormVisible = true;
              this.$nextTick(() => {
                  this.$refs.autofocus1.focus();
              });
          }
          if (flag == 2) {
              if (this.$ddldata.IsAreaMode && this.$tool.getSession(this.$tool.loginutype) != "G" && this.ReqItemRight.hospcode == "All") {
                  this.$confirm("只有管理员才能修改所有医院数据!", "提示", {
                      confirmButtonText: "确定",
                      cancelButtonText: "取消",
                      focusCancelButton: true,
                      closeOnClickModal: false,
                      type: "warning",
                  });
              } else {
                  this.dialogTitle = "修改申请项目字典";
                  this.actionflag = flag;
                  this.ShowUpdate();
                  this.dialogFormVisible = true;
                  this.$nextTick(() => {
                      this.$refs.autofocus1.focus();
                  });
              }
          }
          if (flag == 3) {
              this.actionflag = flag;
              this.tempRowIndex = this.$refs.xTable.getRowIndex(this.$refs.xTable.getCurrentRow());
              this.dialogVisible = true;
          }
      },
      CommitTips() {
          if (this.ReqItem.req_itemcode != "" && this.ReqItem.req_itemname != "" && this.ReqItem.req_itemna != "") {
              this.SaveMain(this.actionflag);
          } else {
              this.$message("项目名称、项目简称和申请项目代码不能为空!");
          }
      },
      CancelTips() {
          if (this.actionflag < 3) {
              this.dialogFormVisible = false;
          } else {
              this.dialogVisible = false;
          }
      },
      clearcache() {
          var clearall = "0";
          if (window.event.ctrlKey) {
              clearall = "1";
          }
          this.$tool
              .request({
                  url: "MNG/MNG2/MNG231",
                  method: "post",
                  data: {
                      action: "clearcache",
                      clearall: clearall,
                  },
              })
              .then((res) => {
                  if (res.flag == 1) {
                      this.$alert("清理成功！");
                  }
              });
      },
      ShowMain(reqitemcode) {
          this.loading = true;
          this.$tool
              .request({
                  url: "MNG/MNG2/MNG231",
                  method: "post",
                  data: {
                      action: "query",
                      // formshow: this.onlyshow ? "1" : "0",
                      disabled: this.disabledflag,
                      searchitemclasscode: this.searchitemclasscode,
                      searchcollectdictid: this.searchcollectdictid,
                      searchitem_price1: this.searchitem_price1,
                      searchitem_price2: this.searchitem_price2,
                      searchoutflag: this.searchoutflag,
                  },
              })
              .then((res) => {
                  this.FirstLoading = true;
                  this.usertype = res.usertype;
                  if (!res.hasOwnProperty("errcode")) {
                      this.tableColumn = res.RData.Cols;
                      if (res.RData.Data) {
                          if (res.RData.Data.length) {
                              var cotaindata = res.RData.Data;
                              cotaindata.sort((a, b) => a.isadd - b.isadd);
                              this.tableData = cotaindata;
                              this.tableTempData = cotaindata;
                              if (this.reqgroupval) this.reqgroupchange(this.reqgroupval);
                              this.loading = false;
                              if (reqitemcode) {
                                  setTimeout(() => {
                                      let curow = this.$refs.xTable.afterFullData.find((item) => item.req_itemcode == reqitemcode);
                                      if (curow) {
                                          if (curow.hospcode.toUpperCase() == "ALL" && this.IsAreaMode && this.usertype != "G") {
                                              this.isused = true;
                                          } else {
                                              this.isused = false;
                                          }
                                          this.$refs.xTable.scrollToRow(curow);
                                          this.$refs.xTable.setCurrentRow(curow);
                                          this.ReqItemRight = curow;
                                          this.SetReqItemRightFlag();
                                          this.DelReqName = curow.req_itemname;
                                          this.tempRowIndex = this.$refs.xTable.getRowIndex(curow);
                                      }
                                  }, 1);
                              }
                          } else {
                              this.tableData = [];
                              this.loading = false;
                          }
                      } else {
                          this.tableData = [];
                          this.loading = false;
                      }
                      this.IsAreaMode = res.IsAreaMode;
                  }
              });
      },
      ShowUpdate() {
          this.$tool
              .request({
                  url: "MNG/MNG2/MNG231",
                  method: "post",
                  data: {
                      action: "queryforupdate",
                      req_itemcode: this.ReqItemRight.req_itemcode,
                  },
              })
              .then((res) => {
                  if (res.Data.length) {
                      var reqdata = res.Data[0];
                      reqdata.create_bylis = reqdata.create_bylis == "1" ? true : false;
                      //  reqdata.sysno = reqdata.sysno == "1" ? true : false;
                      reqdata.comb_flag = reqdata.comb_flag == "1" ? true : false;
                      reqdata.out_flag = reqdata.out_flag == "1" ? true : false;
                      reqdata.disabled = reqdata.disabled == "1" ? true : false;
                      reqdata.tatnoholiday = reqdata.tatnoholiday == "1" ? true : false;
                      reqdata.cxinputpatinfo = reqdata.cxinputpatinfo == "1" ? true : false;
                      reqdata.infection_flag = reqdata.infection_flag == "1" ? true : false;
                      reqdata.nuclein_flag = reqdata.nuclein_flag == "1" ? true : false;
                      reqdata.payinback_flag = reqdata.payinback_flag == "1" ? true : false;
                      if (reqdata.collectdictid) reqdata.collectdictid = reqdata.collectdictid + "";
                      else reqdata.collectdictid = "";
                      this.ReqItem = reqdata;
                      this.OldReqItem = res.oldData[0];
                  }
              });
      },
      ShowDivide() {
          this.loadingDivide = true;
          // this.$tool
          //     .request({
          //         url: "MNG/MNG2/MNG231",
          //         method: "post",
          //         data: {
          //             action: "allspecimen"
          //         }
          //     })
          //     .then(res => {
          //         this.OptionSpec = res;
          //         this.OptionSpec.push({ specimen_code: "*ORIGINAL*", specimen_name: "使用原标本类型(*ORIGINAL*)" });
          //     });
          this.$tool
              .request({
                  url: "MNG/MNG2/MNG231",
                  method: "post",
                  data: {
                      action: "reqdiv",
                      req_itemcode: this.ReqItemRight.req_itemcode,
                  },
              })
              .then((res) => {
                  this.tableColumnDivide = res.Cols;
                  if (res.Data.length) {
                      var cotaindata = res.Data;
                      var masterrow = cotaindata.find((item) => {
                          return item.masterflag == "1";
                      });
                      if (masterrow) {
                          this.mastercode = masterrow.seq;
                      }
                      this.tableDataDivide = cotaindata;
                      this.loadingDivide = false;
                  } else {
                      this.tableDataDivide = [];
                      this.loadingDivide = false;
                  }
              });
      },
      ShowAddRptitem() {
          this.loadingAddRpt = true;
          this.$tool
              .request({
                  url: "MNG/MNG2/MNG231",
                  method: "post",
                  data: {
                      action: "addrptitem",
                      req_itemcode: this.ReqItemRight.req_itemcode,
                  },
              })
              .then((res) => {
                  if (res.Data.length) {
                      var cotaindata = res.Data;
                      this.tableDataAddRpt = cotaindata;
                      this.loadingAddRpt = false;
                  } else {
                      this.tableDataAddRpt = [];
                      this.loadingAddRpt = false;
                  }
              });
      },
      setendtime(code, row) {
          this.rptunitendtimeuseflag = false;
          this.endtime_row = row;
          this.endtime_code = code;

          var times = row.endtime;
          if (!times) {
              times = "";
          }
          if (times.indexOf("|") != -1) {
              var timesArr = times.split("|");
              this.workday_endtime = timesArr[0].replace(/工作日:/, "");
              this.weekend_endtime = timesArr[1].replace(/周末:/, "");
              this.holiday_endtime = timesArr[2].replace(/节假日:/, "");
          }

          this.endtimedialogForm = true;
      },
      CommitEndtime() {
          var workday_endtime = "";
          var weekend_endtime = "";
          var holiday_endtime = "";

          //把值拼成一个
          if (this.workday_endtime != undefined || this.workday_endtime != null) {
              workday_endtime = this.workday_endtime;
          }
          if (this.weekend_endtime != undefined || this.weekend_endtime != null) {
              weekend_endtime = this.weekend_endtime;
          }
          if (this.holiday_endtime != undefined || this.holiday_endtime != null) {
              holiday_endtime = this.holiday_endtime;
          }
          var endtime = "工作日:" + workday_endtime + "|周末:" + weekend_endtime + "|节假日:" + holiday_endtime;

          if (endtime != "工作日:|周末:|节假日:") {
              if (this.rptunitendtimeuseflag) this.rptunitendtime = endtime;
              else this.endtime_row.endtime = endtime;
          } else {
              this.endtime_row.endtime = "";
          }

          this.endtimedialogForm = false;

          this.workday_endtime = "";
          this.weekend_endtime = "";
          this.holiday_endtime = "";
      },
      ShowSpec() {
          this.loadingSpec = true;
          this.$tool
              .request({
                  url: "MNG/MNG2/MNG231",
                  method: "post",
                  data: {
                      action: "specimen",
                      req_itemcode: this.ReqItemRight.req_itemcode,
                  },
              })
              .then((res) => {
                  if (res.Data.length) {
                      var cotaindata = res.Data;
                      this.tableDataSpec = cotaindata;
                      this.loadingSpec = false;
                  } else {
                      this.tableDataSpec = [];
                      this.loadingSpec = false;
                  }
              });
      },
      ShowRptitem() {
          this.loadingRpt = true;
          this.$tool
              .request({
                  url: "MNG/MNG2/MNG231",
                  method: "post",
                  data: {
                      action: "rptitem",
                      req_itemcode: this.ReqItemRight.req_itemcode,
                  },
              })
              .then((res) => {
                  this.copyvisible = true;
                  if (res.Data.length) {
                      var cotaindata = res.Data;
                      this.tableDataRpt = cotaindata;
                      this.loadingRpt = false;
                  } else {
                      this.tableDataRpt = [];
                      this.loadingRpt = false;
                  }
              });
      },
      ShowUnit() {
          this.loadingUnit = true;
          this.$tool
              .request({
                  url: "MNG/MNG2/MNG231",
                  method: "post",
                  data: {
                      action: "unit",
                      req_itemcode: this.ReqItemRight.req_itemcode,
                  },
              })
              .then((res) => {
                  this.tableColumnUnit = res.Cols;
                  if (res.Data.length) {
                      var unitreq = res.Data;
                      for (let i = 0, len = unitreq.length; i < len; i++) {
                          var temp = unitreq[i];
                          unitreq[i].forbidinput = temp.forbidinput > 0 ? true : false;
                          unitreq[i].defaultselect = temp.defaultselect > 0 ? true : false;
                          unitreq[i].specialreqitem = temp.specialreqitem > 0 ? true : false;
                          if (temp.endtime) {
                              var tempendtime = temp.endtime.split("|");
                              if (tempendtime.length > 0 && tempendtime[0] != "") {
                                  unitreq[i].endtime = "工作日:" + tempendtime[0] + "|周末:" + tempendtime[1] + "|节假日:" + tempendtime[2];
                              } else {
                                  unitreq[i].endtime = "";
                              }
                          }
                      }
                      this.tableDataUnit = unitreq;
                      this.loadingUnit = false;
                  } else {
                      this.tableDataUnit = [];
                      this.loadingUnit = false;
                  }
              });
      },
      ShowCollect() {
          this.loadingCollect = true;
          this.$tool
              .request({
                  url: "MNG/MNG2/MNG231",
                  method: "post",
                  data: {
                      action: "querycollection",
                      req_itemcode: this.ReqItemRight.req_itemcode,
                  },
              })
              .then((res) => {
                  if (res.Data.length) {
                      var cotaindata = res.Data;
                      this.tableDataCollect = cotaindata;
                      this.loadingCollect = false;
                  } else {
                      this.tableDataCollect = [];
                      this.loadingCollect = false;
                  }
              });
      },
      ShowPlan() {
          this.loadingPlan = true;
          this.$tool
              .request({
                  url: "MNG/MNG2/MNG231",
                  method: "post",
                  data: {
                      action: "plan",
                      req_itemcode: this.ReqItemRight.req_itemcode,
                  },
              })
              .then((res) => {
                  if (res.Data.length) {
                      this.tableDataPlan = res.Data;
                      this.loadingPlan = false;
                  } else {
                      this.tableDataPlan = [];
                      this.loadingPlan = false;
                  }
              });
      },
      ShowMutex() {
          this.loadingMutex = true;
          this.$tool
              .request({
                  url: "MNG/MNG2/MNG231",
                  method: "post",
                  data: {
                      action: "querymutex",
                      req_itemcode: this.ReqItemRight.req_itemcode,
                  },
              })
              .then((res) => {
                  if (res.Data.length) {
                      var cotaindata = res.Data;
                      this.tableDataMutex = cotaindata;
                      this.loadingMutex = false;
                  } else {
                      this.tableDataMutex = [];
                      this.loadingMutex = false;
                  }
              });
      },
      SaveRecord() {
          var record1 = this.$refs.xTable2.getRecordset();
          var masterrow = this.$refs.xTable2.tableFullData.find((item) => item.masterflag == "1");
          if (!masterrow && this.$refs.xTable2.tableFullData.length > 0) {
              this.$alert("拆分项目请指定主项标识!", "提示");
              return;
          }
          // if (this.masterflag != 1) {
          //     console.log("last", this, masterflag);
          //     this.$message({
          //         message: "主项标志有且仅有一条，请检查修改。",
          //         type: "warning"
          //     });
          //     return false;
          // }
          var record2 = this.$refs.xTable3.getRecordset();
          var record3 = this.$refs.xTable4.getRecordset();
          var record4 = this.lis113perauth ? this.$refs.xTable5.getRecordset() : "";
          var record5 = this.$refs.xTable7.getRecordset();
          var record6 = this.$refs.xTable8.getRecordset();
          let substr = "";
          var isexcute7 = "0";
          if (this.tableDataPlan.length > 0) {
              isexcute7 = "1";
              let subItem = this.tableDataPlan.filter((item) => item.bitemselect == "1");
              subItem.forEach((item) => {
                  substr += item.plan_id + ",";
              });
          }
          var record7 = substr;
          var record8 = this.$refs.xTable6.getRecordset();
          this.SetOptional(record4);
          this.$tool
              .request({
                  url: "MNG/MNG2/MNG231",
                  method: "post",
                  data: {
                      action: "saverecord",
                      req_itemcode: this.ReqItemRight.req_itemcode,
                      urec1: record1,
                      urec2: record2,
                      urec3: record3,
                      urec4: record4,
                      urec5: record5,
                      urec6: record6,
                      urec7: record7,
                      isexcute7: isexcute7,
                      urec8: record8,
                  },
              })
              .then((res) => {
                  if (res.errcode == 1) {
                      this.$message({
                          message: "保存成功",
                          type: "success",
                      });
                      this.$nextTick(() => {
                          this.ShowTabByTabindex(this.curtabindex);
                      });
                  } else {
                      this.$message.error("保存失败:" + res.errmsg);
                  }
              });
      },
      SaveMain(flag) {
          this.AddArray = "";
          var savedata = JSON.parse(JSON.stringify(this.ReqItem));
          savedata.create_bylis = savedata.create_bylis ? "1" : "0";
          //   savedata.sysno = savedata.sysno ? "BLD" : "LIS";
          savedata.comb_flag = savedata.comb_flag ? "1" : "0";
          savedata.out_flag = savedata.out_flag ? "1" : "0";
          savedata.disabled = savedata.disabled ? "1" : "0";
          savedata.tatnoholiday = savedata.tatnoholiday ? "1" : "0";
          savedata.cxinputpatinfo = savedata.cxinputpatinfo ? "1" : "0";
          savedata.infection_flag = savedata.infection_flag ? "1" : "0";
          savedata.nuclein_flag = savedata.nuclein_flag ? "1" : "0";
          savedata.payinback_flag = savedata.payinback_flag ? "1" : "0";

          savedata.sex_flag = savedata.sex_flag == "男性" ? "1" : savedata.sex_flag == "女性" ? "2" : "0";
          savedata.emer_flag = savedata.emer_flag == "常规" ? "0" : savedata.emer_flag == "急诊" ? "1" : "2";
          this.OldReqItem.sex_flag = this.OldReqItem.sex_flag == "男性" ? "1" : this.OldReqItem.sex_flag == "女性" ? "2" : "0";
          this.OldReqItem.emer_flag = this.OldReqItem.emer_flag == "常规" ? "0" : this.OldReqItem.emer_flag == "急诊" ? "1" : "2";
          if (flag == 1) {
              savedata.his_itemcode = savedata.req_itemcode;
              this.AddArray = savedata.req_itemcode;
          }

          if (flag == 3) {
              var row = this.$refs.xTable.getCurrentRow();
              savedata.req_itemcode = row.req_itemcode;
              var req_itemcode = row.req_itemcode;
              let rowindex = this.$refs.xTable.getRowIndex(row);
              if (rowindex > 0) req_itemcode = this.$refs.xTable.afterFullData[rowindex - 1].req_itemcode;
              else if (rowindex != 0) req_itemcode = this.$refs.xTable.afterFullData[rowindex + 1].req_itemcode;
          }
          this.$tool
              .request({
                  url: "MNG/MNG2/MNG231",
                  method: "post",
                  data: {
                      action: "save",
                      saveinfo: savedata,
                      oldinfo: this.OldReqItem,
                      utype: flag,
                  },
              })
              .then((res) => {
                  if (res.errcode == 1) {
                      this.$message({
                          message: "保存成功",
                          type: "success",
                      });
                      this.ShowMain(req_itemcode);
                      this.$nextTick(() => {
                          this.ShowTabByTabindex(this.curtabindex);
                      });
                      this.dialogFormVisible = false;
                      this.dialogVisible = false;
                  } else {
                      this.$message.error("保存失败:" + res.errmsg);
                  }
              });
      },
      AddRecord() {
          var seq = 10;
          switch (this.curtabindex) {
              case 1:
                  if (this.$refs.xTable2.tableData.length > 0) seq = this.$refs.xTable2.tableData[this.$refs.xTable2.tableData.length - 1].seq + 10;
                  //console.log("Addseq", seq);
                  this.$refs.xTable2.insertAt({ seq: seq }, -1);
                  break;
              case 2:
                  if (this.$refs.xTable3.tableData.length > 0) seq = this.$refs.xTable3.tableData[this.$refs.xTable3.tableData.length - 1].seq + 10;
                  this.$refs.xTable3.insertAt({ seq: seq }, -1);
                  break;
              case 3:
                  if (this.$refs.xTable4.tableData.length > 0) seq = this.$refs.xTable4.tableData[this.$refs.xTable4.tableData.length - 1].seq + 10;
                  this.$refs.xTable4.insertAt({ seq: seq }, -1);
                  break;
              case 4:
                  this.dialogTableVisible1 = true;
                  break;
              case 5:
                  if (this.$refs.xTable6.tableData.length > 0) seq = this.$refs.xTable6.tableData[this.$refs.xTable6.tableData.length - 1].seq + 10;
                  this.$refs.xTable6.insertAt({ seq: seq }, -1);
                  break;
              case 6:
                  if (this.$refs.xTable7.tableData.length > 0) seq = this.$refs.xTable7.tableData[this.$refs.xTable7.tableData.length - 1].seq + 10;
                  this.$refs.xTable7.insertAt({ seq: seq }, -1);
                  break;
              case 7:
                  this.$refs.xTable8.insertAt({ mutex_itemcode: "" }, -1);
                  break;
          }
      },
      DelRecord() {
          var table = "";
          switch (this.curtabindex) {
              case 1:
                  table = this.$refs.xTable2;
                  break;
              case 2:
                  table = this.$refs.xTable3;
                  break;
              case 3:
                  table = this.$refs.xTable4;
                  break;
              case 4:
                  table = this.$refs.xTable5;
                  break;
              case 5:
                  table = this.$refs.xTable6;
                  break;
              case 6:
                  table = this.$refs.xTable7;
                  break;
              case 7:
                  table = this.$refs.xTable8;
                  break;
          }
          if ((this.curtabindex >= 1 && this.curtabindex <= 4) || this.curtabindex == 5 || this.curtabindex == 6 || this.curtabindex == 7) {
              var delrow = table.getCurrentRow();
              if (delrow) {
                  if (this.DelIndex < 0) this.DelIndex = table.getRowIndex(delrow);
                  table.remove(delrow);
                  if (this.DelIndex > -1 && table.tableData.length > 0) {
                      if (table.getTableData().fullData.length > this.DelIndex) this.DelIndex = this.DelIndex;
                      else this.DelIndex = this.DelIndex - 1;
                      var selectrow = table.getTableData().fullData[this.DelIndex];
                      this.$nextTick(() => {
                          table.setCurrentRow(selectrow);
                      });
                  } else {
                      var nowdata = table.getTableData().fullData.filter((item) => {
                          return item._XID < delrow._XID;
                      });
                      if (nowdata.length > 0) {
                          var selectrow = nowdata[nowdata.length - 1];
                          this.$nextTick(() => {
                              table.setCurrentRow(selectrow);
                          });
                      }
                  }
              } else {
                  this.$message("请选中要删除的行");
              }
          }
      },
      addrptitem(rptitemcodeinfos) {
          var seq = 0;
          if (this.$refs.xTable5.tableData.length > 0) {
              var seq = this.$refs.xTable5.tableData[this.$refs.xTable5.tableData.length - 1].seq - 0;
          }

          for (let i = 0, len = rptitemcodeinfos.length; i < len; i++) {
              seq += 10;
              var row = {
                  rpt_itemcode: rptitemcodeinfos[i].rpt_itemcode,
                  rpt_itemname: rptitemcodeinfos[i].rpt_itemname,
                  seq: seq,
                  optional: false,
              };
              var isnow = this.$refs.xTable5.tableData.filter((item) => {
                  return item.rpt_itemcode == row.rpt_itemcode;
              });
              if (isnow.length == 0) this.$refs.xTable5.insertAt(row, -1);
          }
          this.dialogTableVisible1 = false;
      },
      SetOptional(record) {
          if (record != "") {
              if (record.insertRecords.length > 0) {
                  for (let i = 0; i < record.insertRecords.length; i++) {
                      record.insertRecords[i].optional = record.insertRecords[i].optional ? "1" : "0";
                  }
              }
              if (record.removeRecords.length > 0) {
                  for (let i = 0; i < record.removeRecords.length; i++) {
                      record.removeRecords[i].optional = record.removeRecords[i].optional ? "1" : "0";
                  }
              }
              if (record.updateRecords.length > 0) {
                  for (let i = 0; i < record.updateRecords.length; i++) {
                      record.updateRecords[i].odata.optional = record.updateRecords[i].odata.optional ? "1" : "0";
                      record.updateRecords[i].cdata.optional = record.updateRecords[i].cdata.optional ? "1" : "0";
                  }
              }
          }
      },
      reqgroupchange(code, name) {
          if (code)
              this.tableData = this.tableTempData.filter((item) => {
                  return item.req_groupid == code;
              });
          else this.tableData = this.tableTempData;
      },
      masterchange(event, row) {
          if (event) {
              var masterrow = this.$refs.xTable2.tableData.filter((item) => {
                  return item.masterflag == "1" && item.seq != row.seq;
              });
              if (masterrow.length > 0) {
                  masterrow[0].masterflag = "0";
                  this.mastercode = row.seq;
              }
          }
      },
      divreqitemcodechange(code, name) {
          var hasit = this.$refs.xTable2.tableData.filter((item) => item.div_req_itemcode == code);
          if (hasit.length > 1) {
              this.$message.error("不能选择重复的项目!");
              hasit[hasit.length - 1].div_req_itemcode = "";
          }
      },
      SpecChange(code, name) {
          var hasit = this.$refs.xTable4.tableData.filter((item) => item.specimen_code == code);
          if (hasit.length > 1) {
              this.$message.error("不能选择重复的项目!");
              hasit[hasit.length - 1].specimen_code = "";
          }
      },
      MutexChange(code, name) {
          var hasit = this.$refs.xTable8.tableFullData.filter((item) => item.mutex_itemcode == code);
          if (hasit.length > 1) {
              this.$message.error("不能选择重复的项目!");
              hasit[hasit.length - 1].mutex_itemcode = "";
          }
      },
      NameInput(value) {
          this.ReqItem.inputcode = this.$pub.CreateInputcode(value, this, 20);
      },
      NameChange(value) {
          if (this.ReqItem.req_itemna == "") {
              this.ReqItem.req_itemna = value;
          }
      },
      Copy() {
          if (this.$refs.xTable5) {
              this.tableCopyData = JSON.parse(JSON.stringify(this.$refs.xTable5.tableData));
          }
      },
      Paste() {
          var tempdata = JSON.parse(JSON.stringify(this.tableCopyData));
          if (this.$refs.xTable5) {
              var len = this.$refs.xTable5.tableData.length;
              var seq = this.$refs.xTable5.tableData[len - 1].seq - 0;
              for (let i = 0, length = tempdata.length; i < length; i++) {
                  var finddata = this.$refs.xTable5.tableData.filter((item) => {
                      return item.rpt_itemcode == tempdata[i].rpt_itemcode;
                  });
                  if (finddata.length == 0) {
                      tempdata[i].seq = seq + 10;
                      seq += 10;
                      this.$refs.xTable5.insertAt(tempdata[i], -1);
                  }
              }
          }
      },
      rowClassName({ row, rowIndex }) {
          if (row.hasOwnProperty("disabled") && row.disabled == "是") {
              return "rm-disable"; //禁用
          }
          let isDirty = this.$refs.xTable.hasRowChange(row);
          if (isDirty) {
              return "row-modify";
          }
          if (this.$refs.xTable.hasRowInsert(row)) return "row-new";
      },
      syncdata() {
          this.loading = true;
          this.$tool
              .request({
                  url: "MNG/MNG2/MNG231",
                  method: "post",
                  timeout: 600000,
                  data: {
                      action: "syncdata",
                  },
              })
              .then((response) => {
                  if (response.err == 0) {
                      let msg = response.msg;
                      if (!msg) msg = "同步数据获取失败！";
                      this.loading = false;
                      this.$alert(msg);
                      return;
                  }
                  let msg = response.msg;
                  if (!msg) msg = "申请项目同步完成！";
                  this.$alert(msg);
                  this.ShowMain();
                  // let data = response.data;
                  // let _this = this;
                  // data.forEach(item => {
                  //     let rest = this.tableData.filter(element => element.req_itemcode == item.req_itemcode);
                  //     if (rest.length > 0) {
                  //         try {
                  //             this.tableData.forEach(ele => {
                  //                 if (ele.req_itemcode == item.req_itemcode) {
                  //                     ele.req_itemname = item.req_itemname;
                  //                     ele.item_price = item.item_price;
                  //                     ele.itemclasscode = item.itemclasscode;
                  //                     ele.perform_dept = item.perform_dept;
                  //                     ele.his_itemcode = item.his_itemcode == "" ? item.req_itemcode : item.his_itemcode;
                  //                     ele.his_itemname = item.his_itemname == "" ? item.req_itemname : item.his_itemname;
                  //                     ele.hospcode = item.hospcode;
                  //                     ele.inputcode = item.inputcode;
                  //                     throw Error();
                  //                 }
                  //             });
                  //         } catch (e) {}
                  //     } else {
                  //         let initialdata = {
                  //             req_itemcode: item.req_itemcode,
                  //             req_itemname: item.req_itemname,
                  //             item_price: item.item_price,
                  //             itemclasscode: item.itemclasscode,
                  //             perform_dept: item.perform_dept,
                  //             his_itemcode: item.his_itemcode,
                  //             his_itemname: item.his_itemname,
                  //             hospcode: item.hospcode,
                  //             create_bylis: "0",
                  //             sex_flag: "0",
                  //             emer_flag: "2",
                  //             comb_flag: "0",
                  //             out_flag: "0",
                  //             inputcode: item.inputcode
                  //         };
                  //         this.$refs.xTable.insert(initialdata);
                  //     }
                  // });
                  // this.isshow = false;
                  // this.loading = false;
                  // this.$message({
                  //     type: "warining",
                  //     message: "申请项目字典数据更新完成！"
                  // });
              })
              .catch((e) => {
                  console.log("error", e);
                  this.loading = false;
              });
      },
      savesyncdata() {
          let saveinfo = this.$refs.xTable.getRecordset();
          this.$tool
              .request({
                  url: "MNG/MNG2/MNG231",
                  method: "post",
                  data: {
                      action: "savesyncdata",
                      saveinfo: saveinfo,
                  },
              })
              .then((res) => {
                  if (res.errcode == 1) {
                      this.$message({
                          message: "保存成功",
                          type: "success",
                      });
                      this.ShowMain();
                      this.$nextTick(() => {
                          this.isshow = true;
                          this.ShowTabByTabindex(this.curtabindex);
                      });
                  } else {
                      this.$message.error("保存失败:" + res.errmsg);
                  }
              });
      },
      //回车事件
      Funautofocus(elementIndex) {
          let that = this;
          if (that.$refs["autofocus" + elementIndex]) {
              that.$nextTick(() => {
                  let thisElement = that.$refs["autofocus" + elementIndex];
                  // 上一控件失焦
                  if (thisElement.type == "text" || thisElement.type == "textarea") {
                      // 正常输入框或多行输入框
                      thisElement.blur();
                  } else if (thisElement.checkboxSize || thisElement.radioSize) {
                      // 复选框或单选框
                      thisElement.$el.blur();
                  } else if (thisElement.type == "date") {
                      // 日期
                      // TODO：日期选择器不支持回车失焦事件的触发，待研究
                      thisElement.$refs.reference.$refs.input.blur();
                  } else if (thisElement.$refs.ddlmainSelect) {
                      // 下拉框
                      thisElement.$refs.ddlmainSelect.blur();
                  }

                  let index = elementIndex + 1;
                  let nextElement = this.GetNextEnableElement(that, index);
                  // 下一控件聚焦
                  if (nextElement) {
                      if (nextElement.type == "text" || nextElement.type == "textarea") {
                          // 正常输入框或多行输入框
                          nextElement.focus();
                      } else if (nextElement.checkboxSize || nextElement.radioSize) {
                          // 复选框或单选框
                          nextElement.$el.focus();
                      } else if (nextElement.type == "date") {
                          // 日期
                          nextElement.$refs.reference.$refs.input.focus();
                      } else if (nextElement.$refs.ddlmainSelect) {
                          // 下拉框
                          nextElement.$refs.ddlmainSelect.focus();
                      }
                  }
              });
          }
      },
      // 获取下一控件禁用状态，如果禁用的话获取再下一控件
      GetNextEnableElement(that, index) {
          let element = that.$refs["autofocus" + index];
          if (element) {
              if (!element.disabled) {
                  return element;
              }
              index++;
              return this.GetNextEnableElement(that, index);
          } else {
              // undefined
              return element;
          }
      },
      BtnExport() {
          let extableColumn = [];
          var rightlocalStorage = JSON.parse(window.localStorage.getItem(this.excolPro + "exportCol"));
          let tableColumn = this.$refs.xTable.getColumns();
          // tableColumn.forEach((item) => {
          //     this.tableColumn.push({ title: item.title, field: item.property });
          // });

          if (rightlocalStorage && rightlocalStorage.length > 0) {
              rightlocalStorage.forEach((item) => {
                  extableColumn.push({
                      title: item.extitle ? item.extitle : item.title,
                      field: item.property,
                  });
              });
          } else {
              tableColumn.forEach((item) => {
                  extableColumn.push({ title: item.title, field: item.property });
              });
          }

          this.$pub.exportTableExcel(this.tableData, extableColumn, "MNG231 申请项目字典.xlsx");
      },
      setExportColumn() {
          let allColumnList = [];
          this.$refs.xTable.getColumns().forEach((element) => {
              if (element.property) {
                  allColumnList.push({
                      title: element.title,
                      property: element.property,
                  });
              }
          });
          this.allTableCol = allColumnList;
          this.chooseColumndialogVisible = true;
      },
      saveExportColumn() {
          this.chooseColumndialogVisible = false;
      },
      popMultipleChk(e, fieldname, option, title) {
          let temp = XE.clone(option, true);
          this.option1 = [];
          this.option2 = [];
          if (e != "") {
              let k = e.split(",");
              k.forEach((item) => {
                  let ndata = temp.find((m) => m.data == item);
                  if (ndata != undefined && ndata != null) {
                      this.option2.push(ndata);
                  }
              });
              temp.forEach((item) => {
                  if (k.indexOf(item.data + "") < 0) {
                      this.option1.push(item);
                  }
              });
          } else {
              this.option1 = temp;
          }
          this.fieldname = fieldname;
          this.multichktitle = title;
          this.dialogMultipleVisible = true;
      },
      closedialog(value, name) {
          if (value != "close") {
              this[name] = value;
          }
          this.dialogMultipleVisible = false;
      },
  },
};
</script>

<style scoped>
/deep/.el-button--primary {
  color: black;
}
/deep/.vxe-input--wrapper .vxe-input {
  height: auto;
  width: 200px;
  border-radius: 0px;
}
/deep/.el-button--default.btn-custom-cancel {
  float: right !important;
  margin-left: 10px;
}
/deep/.el-input.is-disabled .el-input__inner {
  background-color: #f5f7fa;
  /* border-color: #E4E7ED; */
  color: #000000;
  cursor: not-allowed;
}
.pagetop {
  left: 0;
  right: 0;
  height: 70px;
  display: -webkit-box;
  -webkit-box-pack: center;
  -webkit-box-align: center;
  border: solid 1px #ccc;
  position: absolute;
  z-index: 99;
  overflow-x: auto;
  overflow-x: overlay;
}
.operation-list {
  float: right;
  margin-right: 5px;
  margin-bottom: 5px;
}
.pagecenter {
  position: absolute;
  top: 80px;
  width: 100%;
  left: 0;
  bottom: 0px;
  overflow: auto;
}

.middle-center {
  position: absolute;
  height: 100%;
  right: 805px;
  left: 0;
}

.middle-right {
  background-color: chartreuse;
  position: absolute;
  top: 0;
  bottom: 2px;
  width: 800px;
  right: 0px;
}

table tr td:nth-child(odd) {
  text-align: right;
  white-space: nowrap;
}
table tr td:nth-child(even) {
  text-align: left;
}
table {
  font-size: 12px;
  border-collapse: separate;
  border-spacing: 5px;
}
/deep/.el-checkbox__inner::after {
  border: 2px solid #000000 !important;
  box-sizing: content-box;
  content: "";
  border-left: 0 !important;
  border-top: 0 !important;
  height: 7px;
  left: 4px;
  position: absolute;
  top: 1px;
  transform: rotate(45deg) scaleY(0);
  width: 3px;
  transition: transform 0.15s ease-in 0.05s;
  transform-origin: center;
}
/deep/.el-checkbox__input.is-disabled + span.el-checkbox__label {
  color: #000000;
  cursor: not-allowed;
}
/deep/ .el-checkbox__input.is-disabled .el-checkbox__inner,
.el-checkbox__input.is-disabled.is-checked .el-checkbox__inner + .el-input.is-disabled .el-input__inner {
  background-color: #ffffff !important;
}
/deep/ tr.vxe-body--row.row-modify {
  color: blue !important;
}
/deep/ tr.vxe-body--row.row-new {
  color: red !important;
}
.border-firstcard {
  height: 100%;
  overflow-y: auto;
}

/deep/.el-button.is-disabled {
  border: 0px;
  color: grey;
  background-color: #e6e6e6;
  font-weight: normal;
}
</style>